package cn.hwl.springframework.beans.factory.support;

import cn.hwl.springframework.beans.factory.config.SingletonBeanRegistry;

import java.util.HashMap;
import java.util.Map;

/**
 * @author :  HuangWL
 * @date :    2022/4/22 18:20
 * （第一层）获取单例接口的基本实现：实现原接口方法，增加了受保护方法(添加单例)，可被继承调用
 */
public class DefaultSingletonBeanRegistry implements SingletonBeanRegistry {

    Map<String,Object> singletonObjects  = new HashMap<>();

    @Override
    public Object getSingleton(String beanName) {
        return this.singletonObjects.get(beanName);
    }

    protected void addSingleton(String beanName,Object singletonObject){
        this.singletonObjects.put(beanName, singletonObject);
    }
}
